//
//  PublicActityController.m
//  PublicActivity
//
//  Created by manman on 16/9/7.
//  Copyright © 2016年 manman. All rights reserved.
//
//内存: ?    加载图片??
#import "HMPublicActityController.h"
#import "Masonry.h"

@interface HMPublicActityController ()<UIWebViewDelegate>
//属性WebView
@property(weak,nonatomic)UIWebView *webView;
@end

@implementation HMPublicActityController

-(void)clickBackHome{
    [self loadData];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self setupUI];
    
    [self loadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)setupUI
{
////  添加上面左边的按钮
    UIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"列表.png"] style:UIBarButtonSystemItemDone target:self action:@selector(clickBackHome)];
    self.navigationItem.leftBarButtonItem = leftBarItem;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
//创建一个webView  是否-64
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width ,[UIScreen mainScreen].bounds.size.height-49-64)];
  
    // 把webView添加到视图上
    [self.view addSubview:webView];
    self.webView = webView;
    NSLog(@"%@",NSStringFromCGRect(self.webView.frame));
//  webView的代理
    self.webView.delegate = self;
//  webView自动对页面进行适配
    webView.scalesPageToFit = YES;
    
}


#pragma mark-UIWebViewDelegate
//可以拦截  HTML中的点击事件
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    
     NSLog(@"shouldStartLoad--   %@",request);
    
    //跳转需要有返回按钮?  在导航栏中

    return YES;
}

//js调用OC  注入
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    NSLog(@"%@",webView);
}



-(void)loadData{
    //  创建URL   http://3g.xywy.com/so/?channel=zongheSo&f_s=expert&fromurl=xywy_app        http://3g.yao.xywy.com/?fromurl=xywy_app
    NSURL *URL = [NSURL URLWithString:@"http://3g.yao.xywy.com/?fromurl=xywy_app"];
    //  创建并发送请求
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];
    //   加载数据
    [self.webView loadRequest:request];
}
@end
